﻿using System;
using System.Windows.Forms;

namespace DotNet.Common
{
    public class UpDownMinMaxBox
    {
        public static void Load(NumericUpDown minBox, NumericUpDown maxBox)
        {
            minBox.ValueChanged += delegate(object sender, EventArgs e)
            {
                if (maxBox.Value < minBox.Value)
                {
                    maxBox.Value = minBox.Value;
                }
            };

            maxBox.ValueChanged += delegate(object sender, EventArgs e)
            {
                if (minBox.Value > maxBox.Value)
                {
                    minBox.Value = maxBox.Value;
                }
            };
        }
    }
}
